package love.xin.adapter


import android.content.Context
import android.net.Uri
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import love.xin.databinding.EventItemBinding
import love.xin.databinding.ImageItemBinding
import love.xin.entity.Event
import love.xin.util.DataUtil.Companion.getEventData


class ImageAdapter (private val context: Context,private val list: MutableList<String>) : RecyclerView.Adapter<ImageAdapter.ViewHolder>() {
    inner class ViewHolder(private val bin: ImageItemBinding) : RecyclerView.ViewHolder(bin.root) {

        fun bind(url: String) {
            Log.d("bind", "bind: $url")
            bin.image.setImageURI(Uri.parse(url))

        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(ImageItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))

    }

    override fun getItemCount(): Int =list.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bind(list[position])
    }


}
